package org.example.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.example.entity.DepartmentalStructure;
import org.example.entity.Emp;
import org.example.entity.Employee;
import org.example.models.R;
import org.example.service.EmpService;
import org.example.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/emp")
public class EmpController {
    @Autowired
    EmployeeService employeeService;
    @GetMapping()
    public R<List<Employee>> page(
            @RequestParam(name="employeeName",required = false) String employeeName
    ){
        QueryWrapper<Employee> queryWrapper = new QueryWrapper<>();
        if(employeeName != null){
            queryWrapper.lambda().like(Employee::getEmployeeName,employeeName);
        }
        List<Employee> empList = employeeService.list(queryWrapper);
        return R.success(empList);
    }
}
